const fs = require('fs');

const filePath = 'd:\\Users\\zhansiji\\entry\\src\\main\\ets\\commos\\types.ets';

// 根据之前的分析，原始的 id 分布模式
const originalIdPattern = [
    // 1-59 (A开头单词)
    ...Array.from({length: 59}, (_, i) => i + 1),
    // 250-289 (B开头单词)
    ...Array.from({length: 40}, (_, i) => i + 250),
    // 350-400 (C开头单词)
    ...Array.from({length: 51}, (_, i) => i + 350),
    // 290-338 (更多C开头单词)
    ...Array.from({length: 49}, (_, i) => i + 290),
    // 60-249 (剩余单词)
    ...Array.from({length: 190}, (_, i) => i + 60),
    // 338-349 (最后的单词)
    ...Array.from({length: 12}, (_, i) => i + 338)
];

// 读取文件内容
let content = fs.readFileSync(filePath, 'utf8');

// 恢复原始的混乱 id 分布
let counter = 0;
content = content.replace(/id:\s*\d+/g, () => {
    if (counter < originalIdPattern.length) {
        return `id: ${originalIdPattern[counter++]}`;
    }
    return `id: ${counter++}`;
});

// 写回文件
fs.writeFileSync(filePath, content, 'utf8');

console.log(`已成功恢复原始的 id 分布，共处理了 ${counter} 个条目`);